<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>商品列表</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/themes/icon.css"/>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/demo.css"/>
	<script src="${pageContext.request.contextPath }/plugins/jQuery/jquery.min.js"></script>
	<script src="${pageContext.request.contextPath }/plugins/jQuery/jquery.easyui.min.js"></script>
	<script type="text/javascript">
		$(function(){
			loadTable();
			$('#dlg').dialog('close');
			
		});
		
		function loadTable(){
			$('#dg').datagrid({
				rownumbers:true,
				singleSelect:true,
				pagination:true,
				pageSize:10,
				pageList:[10,20,30,50,100],
		 		url:'${pageContext.request.contextPath }/goods/goodslist',
	    		columns:[[
					{field:'goods_id',title:'商品编号',align:'center',width:80},
					{field:'goods_name',title:'商品名称',align:'center',width:200},
					{field:'goods_kindname',title:'商品类别',align:'center',width:100},
					{field:'goods_place',title:'商品产地',align:'center',width:100},
					{field:'goods_packingname',title:'商品包装',align:'center',width:100},
					{field:'goods_spec',title:'重量（含包装）',align:'center',width:100},
					{field:'sale_price',title:'商品价格',align:'center'},
					{field:'unit_price',title:'每公斤价',width:130,align:'center'},
					{field:'store_num',title:'销售库存',width:130,align:'center'},
					{field:'put_time',title:'上架时间',width:130,align:'center'},
					{field:'goods_statusname',title:'商品状态',width:80,align:'center'}
	 			]],
				onLoadSuccess:function(data){  
			        $("a[name='on_use']").linkbutton({text:'启用',plain:true,iconCls:'icon-my-enable'});
			        $("a[name='no_use']").linkbutton({text:'禁用',plain:true,iconCls:'icon-my-disable'});
			        $("a[name='edit']").linkbutton({text:'编辑',plain:true,iconCls:'icon-edit'});
			        $("a[name='delPerson']").linkbutton({text:'删除',plain:true,iconCls:'icon-person-remove'});  
			        $("a[name='addPerson']").linkbutton({text:'恢复',plain:true,iconCls:'icon-person-add'});  
			        $("a[name='manage']").linkbutton({text:'管理',plain:true,iconCls:'icon-my-manage'}); 
			        $("a[name='resetPass']").linkbutton({text:'重置密码',plain:true,iconCls:'icon-my-set'});
			        $("a[name='show']").linkbutton({text:'查看',plain:true,iconCls:'icon-search'});   
				}
			});
		}
		
		function showImg(imgUrl){
			$('#dlg').dialog('open');
			var image=document.getElementById("stationImg");
			var src="${pageContext.request.contextPath }"+imgUrl;
			image.setAttribute("src",src );
		}
		
		function edit(channelId){
			show("${pageContext.request.contextPath}/admin/channel/editBefore/"+channelId,"修改栏目信息");
			
		}
		// 重置密码功能，重置的密码为随机生成的6位数字
		function resetPass(userid){
			var pass=getRandomPass();
			$.post("${pageContext.request.contextPath}/admin/user/resetPass",{userid:userid,password:pass},
				function(data){
					if(data=="0"){
						$.messager.alert('系统消息','<span style=\"color:red;\">密码重置失败，请稍后再试！</span>');	 
					}else{
						$.messager.alert('系统消息','密码重置成功！<br/>重置后的密码为：'+pass);
						$('#dg').datagrid('reload'); 
					}
						
				},"text");
		}
		

		// 打开一个新的选项卡，并制定选项卡的名称
		function show(url,name){
			parent.window.addTab(name,url);
		}

	</script>
	<style type="text/css">
		body{
		font-family:'微软雅黑';}
	</style>
  </head>
  
  <body>
    <table id="dg" title="商品列表"></table>
    <div id="dlg" class="easyui-dialog" title="站长头像查看" style="width:270px;height:390px;max-width:800px;padding:10px" data-options="
			onResize:function(){
				$(this).dialog('center');
			}">
			<img id="stationImg" src="" width="220" height="320"/>
	</div>
  </body>
</html>
